package com.algorithm;

/**
 * 链表删除重复数字
 */
public class RemoveDuplicatesFromSortedList {

    public static ListNode deleteDuplicates(ListNode head) {
        ListNode cur=head;
        while (cur!=null&&cur.next!=null){
            if (cur.next.val==cur.val){
                cur.next=cur.next.next;
            }else {
                cur=cur.next;
            }
        }
        return head;
    }

    public static void main(String[] args) {
//        ListNode listNode=new ListNode(1,new ListNode(1,new ListNode(2)));
//        ListNode listNode=new ListNode(1,new ListNode(1,new ListNode(2,new ListNode(3,new ListNode(3)))));
        ListNode listNode=new ListNode(0,new ListNode(0,new ListNode(0,new ListNode(0,new ListNode(0)))));
        ListNode listNode1 = deleteDuplicates(listNode);
        System.out.println(listNode1);
    }
}
